< previous page page_372 next page >

Page 372
Table 10.1. continued
ControlPropertySetting
VB.LabelNameLabel1
BorderStyle1 'Fixed Single
Height315
Left120
Top180
Width1575

After laying out the form, you need to add the code. Enter Listing 10.1 in the general declarations section of the form. This code declares all the form-level variables you use in the project.
Type.gifListing 10.1. Coding the form-level variables.
Option Explicit
'
' form-level vars
'
Dim strDBName As String
Dim strRSName As String
Dim ws As Workspace
Dim db As Database
Dim rs As Recordset
Listing 10.2 shows the code that opens the database and then opens a Dynaset for your use. Add this code to the Form_Load event.
Type.gifListing 10.2. Opening the database and a Dynaset.
Private Sub Form_Load()
    '
    ' open db and rs objects
    '
    strDBName = App.Path & "\..\..\data\books5.mdb"
    strRSName = "Authors"
    '
    Set ws = DBEngine.CreateWorkspace("dbTemp", "admin", "")
    Set db = ws.OpenDatabase(strDBName)
    Set rs = db.OpenRecordset(strRSName, dbOpenTable)
    '
End Sub

 
< previous page page_372 next page >

If you like this book, buy it!